/* eslint-disable */
import {querySpringPercentage} from '~/service/refundReport';
export const departmentKey = 'department';
export const gradeKey = 'grade';
export const subjectKey = 'subject_id';
export const centerKey = 'area';
export const teacherKey = 'teacher_name';
export const splitStr = '|select|';

const department = ({unitId, controlItems}) => ({
    type: 'select',
    key: `${unitId}${splitStr}${departmentKey}`,
    dimensionName: departmentKey,
    label: '学部',
    // 被依赖项；用于改变时，清空控制项
    controlItems,
    optionsConfig: {
        dId: unitId + '_' + departmentKey,
        unitId,
        options: [],
        pager: {}
    },
    props: {
        mode: 'multiple',
        showSearch: true,
        filterOption: false,
    }
});

const grade = ({unitId, controlItems, dependItemKey}) => ({
    type: 'select',
    key: `${unitId}${splitStr}${gradeKey}`,
    dimensionName: gradeKey,
    label: '年级',
    // 被依赖项；用于改变时，清空控制项
    controlItems,
    // 联动
    dependItemKey,
    optionsConfig: {
        dId: unitId + '_' + gradeKey,
        unitId,
        options: [],
        pager: {}
    },
    props: {
        mode: 'multiple',
        showSearch: true,
        filterOption: false,
    }
});

const subject = ({unitId, controlItems, dependItemKey}) => ({
    type: 'select',
    key: `${unitId}${splitStr}${subjectKey}`,
    dimensionName: subjectKey,
    label: '学科',
    // 被依赖项；用于改变时，清空控制项
    controlItems,
    // 联动
    dependItemKey,
    optionsConfig: {
        dId: unitId + '_' + subjectKey,
        unitId,
        options: [],
        pager: {}
    },
    props: {
        mode: 'multiple',
        showSearch: true,
        filterOption: false,
    }
});

const center = ({unitId, controlItems, dependItemKey}) => ({
    type: 'select',
    key: `${unitId}${splitStr}${centerKey}`,
    dimensionName: centerKey,
    label: '中心',
    // 被依赖项；用于改变时，清空控制项
    controlItems,
    // 联动
    dependItemKey,
    optionsConfig: {
        dId: unitId + '_' + centerKey,
        unitId,
        options: [],
        pager: {}
    },
    props: {
        mode: 'multiple',
        showSearch: true,
        filterOption: false,
    }
});

const teacher = ({unitId, controlItems, dependItemKey}) => ({
    type: 'select',
    key: `${unitId}${splitStr}${teacherKey}`,
    dimensionName: teacherKey,
    label: '主讲',
    // 被依赖项；用于改变时，清空控制项
    controlItems,
    // 联动
    dependItemKey,
    optionsConfig: {
        dId: unitId + '_' + teacherKey,
        unitId,
        options: [],
        pager: {}
    },
    props: {
        mode: 'multiple',
        showSearch: true,
        filterOption: false,
    }
});

export const selectDId1 = 'Center_Dimension_partThree_select';
export const selectDId2 = 'Center_Dimension_partFour_select';
export const selectDId3 = 'Center_Dimension_partFive_select';
export const selectDId4 = 'Center_Dimension_partSix_select';
export const selectDId5 = 'Center_Dimension_partSeven_Speaker_Ranking_select';
export const selectDIdTitle = 'Center_Dimension_Title_select';

export const dIdConfig = {
    center: 'Center_Dimension_partThree_Renewal_Accomplish',
    subject: 'Center_Dimension_partFour_Subject_Transformation',
    grade: 'Center_Dimension_partFive_Grade_Transformation',
    age: 'Center_Dimension_partSix_Assistant_Work_Time',
    classNum: 'Center_Dimension_partSix_Renewal_Num',
    centerRank: 'Center_Dimension_partSeven_Speaker_Ranking',
};
// 需要隐藏的列 [id, type]
export const hidenColumnsConfigGeneral = [
    ['Center_Dimension_partTwo_Center_Basic_excel_can_renewal_num_sum_late_1', 2],
    ['Center_Dimension_partTwo_Center_Basic_excel_can_renewal_num_sum_late_2', 2],
    ['Center_Dimension_partTwo_Center_Basic_excel_total_renewal_percentage_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_total_renewal_percentage_late_2', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_accomplished_percentage_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_accomplished_percentage_late_2', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_comprehensive_target_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_comprehensive_target_renewal_num_sum_late_2', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_pure_renewal_percentage_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_pure_renewal_percentage_late_2', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_target_completion_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_target_completion_renewal_num_sum_late_2', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_target_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partTwo_Center_Basic_excel_target_renewal_num_sum_late_2', 3]
];
// 需要隐藏的列 [id, type]
const hidenColumnsConfigRank = [
    ['Center_Dimension_partSeven_Speaker_Ranking_can_renewal_num_sum_late_1', 2],
    ['Center_Dimension_partSeven_Speaker_Ranking_can_renewal_num_sum_late_2', 2],
    ['Center_Dimension_partSeven_Speaker_Ranking_total_renewal_percentage_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_total_renewal_percentage_late_2', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_accomplished_percentage_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_accomplished_percentage_late_2', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_comprehensive_target_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_comprehensive_target_renewal_num_sum_late_2', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_pure_renewal_percentage_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_pure_renewal_percentage_late_2', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_target_completion_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_target_completion_renewal_num_sum_late_2', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_target_renewal_num_sum_late_1', 3],
    ['Center_Dimension_partSeven_Speaker_Ranking_target_renewal_num_sum_late_2', 3]
];

// 复合图配置
export const partConfig = [
    {
        id: dIdConfig.center,
        title: '中心转化',
        unitId: `${dIdConfig.center}_composite`,
        selectDId: selectDId1,
        type: 'echarAndTable',
        ajax: querySpringPercentage,
        searchConfig: [
            department({unitId: selectDId1, controlItems: [`${selectDId1}${splitStr}${gradeKey}`, `${selectDId1}${splitStr}${subjectKey}`]}),
            grade({unitId: selectDId1, controlItems: [`${selectDId1}${splitStr}${subjectKey}`], dependItemKey: `${selectDId1}${splitStr}${departmentKey}`}),
            subject({unitId: selectDId1, dependItemKey: `${selectDId1}${splitStr}${gradeKey}`})
        ],
        initialValues: {
            [`${selectDId1}${splitStr}${departmentKey}`]: '全部',
            [`${selectDId1}${splitStr}${gradeKey}`]: '全部',
            [`${selectDId1}${splitStr}${subjectKey}`]: '全部',
        },
        children: [
            {
                type: 'table',
                unitId: `${dIdConfig.center}_excel`,
            },
            {
                type: 'echart',
                unitId: `${dIdConfig.center}_composite`,
            },
        ]
    },
    {
        id: dIdConfig.subject,
        title: '学科转化',
        unitId: `${dIdConfig.subject}_composite`,
        selectDId: selectDId2,
        type: 'echarAndTable',
        ajax: querySpringPercentage,
        searchConfig: [
            department({unitId: selectDId2, controlItems: []}),
            center({unitId: selectDId2, controlItems: [], dependItemKey: ''}),
            grade({unitId: selectDId2, controlItems: [], dependItemKey: ''})
        ],
        initialValues: {
            [`${selectDId2}${splitStr}${departmentKey}`]: '全部',
            [`${selectDId2}${splitStr}${centerKey}`]: '全部',
            [`${selectDId2}${splitStr}${gradeKey}`]: '全部',
        },
        children: [
            {
                type: 'table',
                unitId: `${dIdConfig.subject}_excel`,
            },
            {
                type: 'echart',
                unitId: `${dIdConfig.subject}_composite`,
            },
        ]
    },
    {
        id: dIdConfig.grade,
        title: '年级转化',
        unitId: `${dIdConfig.grade}_composite`,
        selectDId: selectDId3,
        type: 'echarAndTable',
        ajax: querySpringPercentage,
        searchConfig: [
            department({unitId: selectDId3, controlItems: []}),
            center({unitId: selectDId3, controlItems: [], dependItemKey: ''}),
            subject({unitId: selectDId3, controlItems: [], dependItemKey: ''})
        ],
        initialValues: {
            [`${selectDId3}${splitStr}${departmentKey}`]: '全部',
            [`${selectDId3}${splitStr}${centerKey}`]: '全部',
            [`${selectDId3}${splitStr}${subjectKey}`]: '全部',
        },
        children: [
            {
                type: 'table',
                unitId: `${dIdConfig.grade}_excel`,
            },
            {
                type: 'echart',
                unitId: `${dIdConfig.grade}_composite`,
            },
        ]
    },
    {
        title: '',
        unitId: 'gradeTransform_1',
        selectDId: selectDId4,
        searchConfig: [
            department({unitId: selectDId4, controlItems: []}),
            center({unitId: selectDId4, controlItems: [], dependItemKey: ''}),
            grade({unitId: selectDId4, controlItems: [], dependItemKey: ''}),
            subject({unitId: selectDId4, dependItemKey: ''})
        ],
        initialValues: {
            [`${selectDId4}${splitStr}${departmentKey}`]: '全部',
            [`${selectDId4}${splitStr}${centerKey}`]: '全部',
            [`${selectDId4}${splitStr}${gradeKey}`]: '全部',
            [`${selectDId4}${splitStr}${subjectKey}`]: '全部',
        },
        children: [
            {
                id: dIdConfig.age,
                key: 'gradeTransform_2',
                title: '司龄分布',
                span: 12,
                type: 'echarAndTable',
                selectDId: selectDId4,
                children: [
                    {
                        type: 'table',
                        unitId: `${dIdConfig.age}_Partition_1_excel`,
                        columnsConfig: [
                            {name: '司龄'},
                            {name: '[0~3)月'},
                            {name: '[3~6)月'},
                            {name: '[6~12)月'},
                            {name: '12月及以上'},
                        ]
                    },
                    {
                        type: 'echart',
                        unitId: `${dIdConfig.age}_Partition_2_composite`,
                    },
                ],
            },
            {
                id: dIdConfig.classNum,
                title: '带班量分层',
                span: 12,
                selectDId: selectDId4,
                type: 'echarAndTable',
                children: [
                    {
                        type: 'table',
                        unitId: `${dIdConfig.classNum}_Partition_1_excel`,
                        columnsConfig: [
                            {name: '带班量'},
                            {name: '[0~100)'},
                            {name: '[100~150)'},
                            {name: '[150~200)'},
                            {name: '[200~250)'},
                            {name: '250及以上'},
                        ]
                    },
                    {
                        type: 'echart',
                        unitId: `${dIdConfig.classNum}_Partition_2_composite`,
                    },
                ]
            },
        ],
    },
    {
        id: dIdConfig.centerRank,
        title: '同主讲同年级中心排名',
        unitId: `${dIdConfig.centerRank}_Partition_1_excel`,
        selectDId: selectDId5,
        type: 'echarAndTable',
        hidenColumnsConfig: hidenColumnsConfigRank,
        searchConfig: [
            center({unitId: selectDId5, controlItems: []}),
            grade({unitId: selectDId5, controlItems: [], dependItemKey: ''}),
            subject({unitId: selectDId5, controlItems: [], dependItemKey: ''}),
            teacher({unitId: selectDId5, controlItems: [], dependItemKey: ''})
        ],
        initialValues: {
            [`${selectDId5}${splitStr}${centerKey}`]: '全部',
            [`${selectDId5}${splitStr}${gradeKey}`]: '全部',
            [`${selectDId5}${splitStr}${subjectKey}`]: '全部',
            [`${selectDId5}${splitStr}${teacherKey}`]: '全部',
        },
        children: [
            {
                type: 'table',
                unitId: `${dIdConfig.centerRank}_Partition_1_excel`,
                notTransformTable: true,
                pagerVisible: true,
                customRender: true,
                // 0 1 2 冻结
                fixedIdxEnd: 3
            },
        ]
    },
];

// 四个卡片
export const cardsConfig = [
    {
        id: 'Renewal_Overview_partOne_Renewal_Number_city',
        unitId: 'Renewal_Overview_partOne_Renewal_Number_city_card_1',
    },
    {
        id: 'Renewal_Overview_partOne_Total_Renewal_Percentage_city',
        unitId: 'Renewal_Overview_partOne_Total_Renewal_Percentage_city_card_1',
        isRatio: true
    },
    {
        id: 'Renewal_Overview_partOne_Accomplished_Percentage_city',
        unitId: 'Renewal_Overview_partOne_Accomplished_Percentage_city_card_1',
        isRatio: true
    },
    {
        id: 'Renewal_Overview_partOne_Total_Renewal_Money_city',
        unitId: 'Renewal_Overview_partOne_Total_Renewal_Money_city_card_1',
    },
    {
        id: 'Renewal_Overview_partOne_Renewal_Ratio_city',
        unitId: 'Renewal_Overview_partOne_Renewal_Ratio_city_card',
        isRatio: true
    },
    {
        id: 'Renewal_Overview_partOne_Renewal_Target_Ratio_city',
        unitId: 'Renewal_Overview_partOne_Renewal_Target_Ratio_city_card',
        isRatio: true
    },
];

export const searchTitleConfig = [
    {
        type: 'select',
        key: `department`,
        label: '学部',
        optionsConfig: {
            options: [],
            pager: {}
        },
        props: {
            mode: 'multiple'
        }
    },
    {
        type: 'select',
        key: `area`,
        label: '中心',
        optionsConfig: {
            options: [],
            pager: {}
        },
        props: {
            mode: 'multiple'
        }
    },
    {
        type: 'select',
        key: `grade`,
        label: '年级',
        optionsConfig: {
            options: [],
            pager: {}
        },
        props: {
            mode: 'multiple'
        }
    },
    {
        type: 'select',
        key: `subject_id`,
        label: '学科',
        optionsConfig: {
            options: [],
            pager: {}
        },
        props: {
            mode: 'multiple'
        }
    },
];

export const searchTitleInitival = {
    department: ['全部'],
    area: ['全部'],
    grade: ['全部'],
    [`subject_id`]: ['全部']
};

